/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.flf.audioteca.businessdelegate.impl;

import br.edu.flf.audioteca.entidades.Artista;
import br.edu.flf.audioteca.factory.IBOFactory;
import br.edu.flf.audioteca.factory.impl.BOFactory;
import br.edu.flf.audioteca.businessdelegate.IArtistaBusinessDelegate;
import br.edu.flf.audioteca.commandcontrol.ComandosDeControle;
import br.edu.flf.audioteca.dao.exceptions.JPAException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Nathan Azevedo
 */
public class ArtistaBusinessDelegate implements IArtistaBusinessDelegate {

    private static IArtistaBusinessDelegate artistaBusinessDelegate = null;
    private IBOFactory bOFactory;

    public ArtistaBusinessDelegate() {
        bOFactory = BOFactory.getInstance();
    }

    public static IArtistaBusinessDelegate getInstance() {
        if (artistaBusinessDelegate == null) {
            artistaBusinessDelegate = new ArtistaBusinessDelegate();

        }
        return artistaBusinessDelegate;
    }

    public List<Artista> obterTodosOsArtistas() {
        List<Artista> artistas = null;
        try {
            artistas = bOFactory.getArtistaBO().obterTodosOsArtistas();
        } catch (JPAException ex) {
            Logger.getLogger(ArtistaBusinessDelegate.class.getName()).log(Level.SEVERE, null, ex);
        }

        return artistas;
    }

    public String cadastrarArtista(Artista artista) {
        try {
            bOFactory.getArtistaBO().cadastrarArtista(artista);
        } catch (JPAException e) {
            Logger.getLogger(ArtistaBusinessDelegate.class.getName()).log(Level.SEVERE, null, e);
            return ComandosDeControle.ERRO_JPA_CADASTRO_ARTISTA;
        }
        return ComandosDeControle.MOSTRAR_RESULTADOS_CADASTRO_ARTISTA;
    }
}
